package com._23DesignPattern._algorithm._sort;

/**
 * @Author: huangya
 * @Date: 2019/4/13
 * @Description:
 */
public class User implements Comparable<User>{

    private Integer age;

    private Integer score;

    public User(Integer age, Integer score) {
        this.age = age;
        this.score = score;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    @Override
    public int compareTo(User o) {
        int i = this.getAge() - o.getAge();//先按照年龄排序
        if(i == 0){
            return this.score - o.getScore();//如果年龄相等了再用分数进行排序
        }
        return i;
    }

}
